package de.koller.million.grid.engine.player;

import de.koller.oceanFramework.util.GStat;
import de.koller.million.grid.frame.enc.IVolatileValue;

public class PlayerStats {
	
	public final IVolatileValue hpValue = new HPValue();
	
	private double currentHP = 0;
	public final GStat healthPoints = new GStat();
	public final GStat damage = new GStat();
	public final GStat speed = new GStat();
	
	public final GStat foodGen = new GStat();
	
	public void addHP( double dhp ) {
		setCurrentHP( currentHP + dhp );
	}
	
	public void setCurrentHP( double hp ) {
		currentHP = hp;
		
		if( currentHP > healthPoints.getValue() )
			currentHP = healthPoints.getValue();
		if( currentHP < 0 )
			currentHP = -1;
	}
	
	public double getCurrentHP() {
		return currentHP;
	}
	
	private class HPValue implements IVolatileValue {

		@Override
		public double getCurrValue() {
			return currentHP;
		}

		@Override
		public double getMaxValue() {
			return healthPoints.getValue();
		}
		
	}
	
}
